#       smsread.py
#       
#       Copyright 2010 mayli <mayli@matrix>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

#		This file will get all sms in the Inbox and save them into a txt file
#		Modify the path and file as your wish.
from time import ctime

import codecs
import inbox

path = 'E:/Others/listSMS.txt'
box = inbox.Inbox()
msg = box.sms_messages()

f = codecs.open(path, 'w', 'utf8') # Apre il file in codifica UTF8
for i in msg:
	f.write('========')
	f.write(box.address(i))
	f.write('\n')
	f.write(ctime(box.time(i))) # Converte i secondi in una stringa rappresentante il tempo
	f.write('\n')
	f.write(box.content(i))
	f.write('========\n')
f.close()

print 'Done.'

f = codecs.open(path, 'r', 'utf8')
print f.read()
print 'EOF'

f.close()
